__doc__ =   """ Classes for secondary structure assignment.
            """

from AbstractPropertyDict import AbstractResiduePropertyDict
from Einput import einput
from Externals import call_stride   # ss assignment via stride

class SecondaryStructure(AbstractResiduePropertyDict):
    """ Assign residues their secondary structure from structure by Stride.
    """
    def __init__(self, pdb_file, structure, xtra_key =None, **kwargs):
        xtra_key = (xtra_key or 'SS_STRIDE')
        surfaces = call_stride(pdb_file, **kwargs)
        ss_dict = {}
        for ((chain_id, res_full_id), data) in surfaces.iteritems():
            try:
                residue = structure[(0,)][(chain_id,)][(res_full_id,)]
            except KeyError:
                # at least in theory we could loose a residue
                print 'Residue %s %s %s cannot be found in: %s %s' % \
                (res_full_id, structure[(0,)].get_full_id())
                continue
            ss_dict[residue.get_full_id()] = data[0]
            residue.xtra[xtra_key] = data[0]
        AbstractResiduePropertyDict.__init__(self, ss_dict)

#EOF